+2006-09-02 Kristian Rietveld <kris@imendio.com>
+
+ First part of file chooser fixes.
+
+ * gtk/gtkfilechooserbutton.c (model_add_special): also set the
+ handle in the model for the desktopdir case.
+
+ * gtk/gtkfilechooserdefault.c (shortcuts_add_current_folder): free
+ volume in case we retrieved it but don't pass it on to insert_path,
+ (shortcuts_model_create): change the column type for the handles
+ to pointer instead of GObject so our handle ref counting is not
+ disturbed,
+ (show_and_select_paths_finished_loading): don't forget to unref
+ the dialog.
+
+ * gtk/gtkfilesystemunix.c (gtk_file_system_unix_class_init),
+ (gtk_file_system_unix_init), (gtk_file_system_unix_dispose):
+ remove pending execute_callbacks_idle during dispose, also
+ execute all callbacks waiting to be run in the next idle,
+ (queue_*callback), (execute_callbacks_idle): refactor to maintain
+ a list of callbacks to call per file system instead of globally,
+ guard the file system during callback invocation,
+ (gtk_file_system_unix_get_folder): only add load folder idle if
+ none has been added yet.
+
2006-09-01 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkentry.c: Don't unnecessarily reset the im context
shortcuts_insert_path (impl, pos, TRUE, volume, NULL, NULL, FALSE, SHORTCUTS_CURRENT_FOLDER);
}
else
- shortcuts_insert_path (impl, pos, FALSE, NULL, impl->current_folder, NULL, FALSE, SHORTCUTS_CURRENT_FOLDER);
+ {
+ shortcuts_insert_path (impl, pos, FALSE, NULL, impl->current_folder, NULL, FALSE, SHORTCUTS_CURRENT_FOLDER);
+ if (volume)
+ gtk_file_system_volume_free (impl->file_system, volume);
+ }
if (base_path)
gtk_file_path_free (base_path);
G_TYPE_BOOLEAN, /* is the previous column a volume? */
G_TYPE_BOOLEAN, /* removable */
G_TYPE_BOOLEAN, /* pixbuf cell visibility */
- G_TYPE_OBJECT); /* GtkFileSystemHandle */
+ G_TYPE_POINTER); /* GtkFileSystemHandle */
if (impl->file_system)
{
browse_files_center_selected_row (data->impl);
+ g_object_unref (data->impl);
gtk_file_paths_free (data->paths);
g_free (data);
}
GHashTable *handles;
+ guint execute_callbacks_idle_id;
+ GSList *callbacks;
+
guint have_afs : 1;
guint have_net : 1;
};
GTK_FILE_INFO_ICON);
static void gtk_file_system_unix_iface_init (GtkFileSystemIface *iface);
+static void gtk_file_system_unix_dispose (GObject *object);
static void gtk_file_system_unix_finalize (GObject *object);
static GSList * gtk_file_system_unix_list_volumes (GtkFileSystem *file_system);
struct stat *statbuf,
const char *mime_type);
+static gboolean execute_callbacks_idle (gpointer data);
+
static gboolean fill_in_names (GtkFileFolderUnix *folder_unix,
GError **error);
static void fill_in_stats (GtkFileFolderUnix *folder_unix);
{
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
+ gobject_class->dispose = gtk_file_system_unix_dispose;
gobject_class->finalize = gtk_file_system_unix_finalize;
}
system_unix->have_net = FALSE;
system_unix->handles = g_hash_table_new (g_direct_hash, g_direct_equal);
+
+ system_unix->execute_callbacks_idle_id = 0;
+ system_unix->callbacks = NULL;
}
static void
#endif
g_hash_table_destroy (system_unix->handles);
+ system_unix->handles = NULL;
}
#define GTK_TYPE_FILE_SYSTEM_HANDLE_UNIX (_gtk_file_system_handle_unix_get_type ())
gobject_class->finalize = _gtk_file_system_handle_unix_finalize;
}
+static void
+gtk_file_system_unix_dispose (GObject *object)
+{
+ GtkFileSystemUnix *system_unix;
+
+ system_unix = GTK_FILE_SYSTEM_UNIX (object);
+
+ if (system_unix->execute_callbacks_idle_id)
+ {
+ g_source_remove (system_unix->execute_callbacks_idle_id);
+ system_unix->execute_callbacks_idle_id = 0;
+
+ /* call pending callbacks */
+ execute_callbacks_idle (system_unix);
+ }
+
+ G_OBJECT_CLASS (gtk_file_system_unix_parent_class)->dispose (object);
+}
static void
gtk_file_system_unix_finalize (GObject *object)
CALLBACK_VOLUME_MOUNT
};
-static void queue_callback (enum callback_types type, gpointer data);
+static void queue_callback (GtkFileSystemUnix *system_unix, enum callback_types type, gpointer data);
struct get_info_callback
{
info->error = error;
info->data = data;
- queue_callback (CALLBACK_GET_INFO, info);
+ queue_callback (GTK_FILE_SYSTEM_UNIX (handle->file_system), CALLBACK_GET_INFO, info);
}
info->error = error;
info->data = data;
- queue_callback (CALLBACK_GET_FOLDER, info);
+ queue_callback (GTK_FILE_SYSTEM_UNIX (handle->file_system), CALLBACK_GET_FOLDER, info);
}
info->error = error;
info->data = data;
- queue_callback (CALLBACK_CREATE_FOLDER, info);
+ queue_callback (GTK_FILE_SYSTEM_UNIX (handle->file_system), CALLBACK_CREATE_FOLDER, info);
}
info->error = error;
info->data = data;
- queue_callback (CALLBACK_VOLUME_MOUNT, info);
+ queue_callback (GTK_FILE_SYSTEM_UNIX (handle->file_system), CALLBACK_VOLUME_MOUNT, info);
}
};
-static guint execute_callbacks_idle_id = 0;
-static GSList *callbacks = NULL;
static gboolean
execute_callbacks_idle (gpointer data)
{
GSList *l;
+ gboolean unref_file_system = TRUE;
+ GtkFileSystemUnix *system_unix = GTK_FILE_SYSTEM_UNIX (data);
GDK_THREADS_ENTER ();
- for (l = callbacks; l; l = l->next)
+ if (!system_unix->execute_callbacks_idle_id)
+ unref_file_system = FALSE;
+ else
+ g_object_ref (system_unix);
+
+ for (l = system_unix->callbacks; l; l = l->next)
{
struct callback_info *info = l->data;
g_free (info);
}
- g_slist_free (callbacks);
- callbacks = NULL;
+ g_slist_free (system_unix->callbacks);
+ system_unix->callbacks = NULL;
+
+ if (unref_file_system)
+ g_object_unref (system_unix);
- execute_callbacks_idle_id = 0;
+ system_unix->execute_callbacks_idle_id = 0;
GDK_THREADS_LEAVE ();
}
static void
-queue_callback (enum callback_types type, gpointer data)
+queue_callback (GtkFileSystemUnix *system_unix,
+ enum callback_types type,
+ gpointer data)
{
struct callback_info *info;
break;
}
- callbacks = g_slist_append (callbacks, info);
+ system_unix->callbacks = g_slist_append (system_unix->callbacks, info);
- if (!execute_callbacks_idle_id)
- execute_callbacks_idle_id = g_idle_add (execute_callbacks_idle, NULL);
+ if (!system_unix->execute_callbacks_idle_id)
+ system_unix->execute_callbacks_idle_id = g_idle_add (execute_callbacks_idle, system_unix);
}
static GtkFileSystemHandle *
queue_get_folder_callback (callback, handle, GTK_FILE_FOLDER (folder_unix), NULL, data);
/* Start loading the folder contents in an idle */
- folder_unix->load_folder_id =
- g_idle_add ((GSourceFunc) load_folder, folder_unix);
+ if (!folder_unix->load_folder_id)
+ folder_unix->load_folder_id =
+ g_idle_add ((GSourceFunc) load_folder, folder_unix);
return handle;
}